package com.situ.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

import com.situ.bean.Dept;

public interface DeptMapper {
	@Delete({ "delete from dept", "where id = #{id,jdbcType=INTEGER}" })
	int deleteByPrimaryKey(Integer id);

	@Insert({ "insert into dept ( name, ", "room, phone)", "values (#{name}, ", "#{room}, #{phone})" })
	@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
	int insert(Dept record);

	@Select({ "select", "id, name, room, phone", "from dept", "where id = #{id,jdbcType=INTEGER}" })
	@Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
			@Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
			@Result(column = "room", property = "room", jdbcType = JdbcType.VARCHAR),
			@Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR) })
	Dept selectByPrimaryKey(Integer id);

	@Select({ "select", "id, name, room, phone", "from dept" })
	@Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true),
			@Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
			@Result(column = "room", property = "room", jdbcType = JdbcType.VARCHAR),
			@Result(column = "phone", property = "phone", jdbcType = JdbcType.VARCHAR) })
	List<Dept> selectAll();

	@Update({ "update dept", "set name = #{name,jdbcType=VARCHAR},", "room = #{room,jdbcType=VARCHAR},",
			"phone = #{phone,jdbcType=VARCHAR}", "where id = #{id,jdbcType=INTEGER}" })
	int updateByPrimaryKey(Dept record);
}